//
//  TestViewController.swift
//  Example
//
//  Created by xx on 2025/4/14.
//

import UIKit
import FastSwiftSDK

class DefaultTestViewController: FastViewController {

    private lazy var lbl_device : FastLabel = {
        let lbl =  FastLabel.init("请选择设备")
        return  lbl
    } ()
    
    private lazy var logView : FastTextView = {
        let view =  FastTextView.init()
        return  view
    } ()
    
    private lazy var msgView : FastTextField = {
        let txt =  FastTextField.init()
        return  txt
    } ()
    
    private lazy var btnSend : FastButton = {
        let btn =  FastButton.init(title: "发送");
        btn.click = { [weak self] in
            
        }
        return  btn
    } ()
    
    private lazy var btnForward : FastButton = {
        let btn =  FastButton.init(title: "前进");
        btn.tag = 1
        btn.addTarget(self, action: #selector(btnAction(_:)), for: .touchDown)
        btn.addTarget(self, action: #selector(stopAction), for: .touchCancel)
        self.view.addSubview(btn)
        return  btn
    } ()
    
    private lazy var btnLeft : FastButton = {
        let btn =  FastButton.init(title: "左");
        btn.tag = 2
        btn.addTarget(self, action: #selector(btnAction(_:)), for: .touchDown)
        btn.addTarget(self, action: #selector(stopAction), for: .touchCancel)
        self.view.addSubview(btn)
        return  btn
    } ()
    
    private lazy var btnRight : FastButton = {
        let btn =  FastButton.init(title: "右");
        btn.tag = 3
        btn.addTarget(self, action: #selector(btnAction(_:)), for: .touchCancel)
        btn.addTarget(self, action: #selector(stopAction), for: .touchDown)
        self.view.addSubview(btn)
        return  btn
    } ()
    
    private lazy var btnStop : FastButton = {
        let btn =  FastButton.init(title: "停止");
        btn.click = { [weak self] in
//            XXNetWorking.shared.boatStop()
        }
        self.view.addSubview(btn)
        return  btn
    } ()
    
    @objc func btnAction(_ sender:UIButton){
        if sender.tag == 1{
//            XXNetWorking.shared.boatForward()
        }
        if sender.tag == 2{
//            XXNetWorking.shared.boatLeft()
        }
        if sender.tag == 3{
//            XXNetWorking.shared.boatRight()
        }
        
        print("1111111")
    }
    
    @objc func stopAction(){
//        XXNetWorking.shared.boatStop()
        print("222222")
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
        btnForward.snp.makeConstraints { make in
            make.left.top.equalTo(50)
            make.width.equalTo(50)
            make.height.equalTo(30)
        }
        
        btnLeft.snp.makeConstraints { make in
            make.width.height.top.equalTo(btnForward)
            make.left.equalTo(btnForward.snp.right).offset(10)
        }
        
        btnRight.snp.makeConstraints { make in
            make.width.height.top.equalTo(btnForward)
            make.left.equalTo(btnLeft.snp.right).offset(10)
        }
        
        btnStop.snp.makeConstraints { make in
            make.width.height.top.equalTo(btnForward)
            make.left.equalTo(btnRight.snp.right).offset(10)
        }
    }
    
    
    


}
